package com.shxy.common.enums;

/**
 * 角色枚举
 */
public enum RoleCode {
    // 角色分类
    ADMIN(1,"admin", "管理员"),
    TOURIST(2,"tourist", "游客"),
    TEACHER(3, "teacher", "教师用户"),
    STUDENT(4, "student", "学生用户");

    private Integer code;
    private String name;
    private String chName;

    RoleCode(int code, String name, String chName) {
        this.code = code;
        this.name = name;
        this.chName = chName;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getChName() {
        return chName;
    }

    public void setChName(String chName) {
        this.chName = chName;
    }

    public static String getNameByCode(int code) {
        for(RoleCode r : values()) {
            if(r.getCode().equals(code)) {
                return r.getName();
            }
        }
        return null;
    }

    public static RoleCode getByCode(int code) {
        for(RoleCode r : values()) {
            if(r.getCode().equals(code)) {
                return r;
            }
        }
        return null;
    }
}
